package com.jiangyao.model.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;

/**
 * 列表分页DTO
 *
 * @author: yangyongchuan
 * @create: 2020年06月09日 00:31
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ListPageDTO implements BaseDTO {
	/**
	 * 页码
	 */
	@Range(min = 1, max = Integer.MAX_VALUE, message = "页码不正确", groups = {ListPage.class})
	@ApiModelProperty(value = "页码", example = "1")
	private Integer pageNo = 1;

	/**
	 * 每页条数
	 */
	@Range(min = 1, max = 100, message = "每页条数不正确", groups = {ListPage.class})
	@ApiModelProperty(value = "每页条数", example = "10")
	private Integer pageSize = 10;

	/**
	 * 查询limit 开始位置
	 */
	@ApiModelProperty(hidden = true)
	private Integer start = 0;

	public Integer getStart() {
		return (pageNo - 1) * pageSize;
	}
}
